home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Games / NeXTmille / Source / CardHolder.m < prev    next >
Text File  |  1990-12-01  |  3KB  |  224 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "CardHolder.h"
  5. #import    "angled_title.h"
  6. #import    "prototypes.h"
  7. #import    <libc.h>
  8. #import    <math.h>
  9. #import    <objc/objc.h>
  10. #import    <stdio.h>
  11. #import    <string.h>
  12.  
  13.  
  14. @implementation CardHolder
  15.  
  16.  
  17. + newFrame:( const NXRect * )frameRect
  18. {
  19.  
  20.     
  21.     self            = [ super newFrame:frameRect ];
  22.     frameModeFlag    = NO;
  23.     myTitle            = calloc( 1, 1 );
  24.     
  25.     return self;
  26. }
  27.  
  28.  
  29. - free
  30. {
  31.  
  32.     free( myTitle );
  33.     
  34.     return [ super free ];
  35. }
  36.  
  37.  
  38. - sendCard:( CardView * )aCard to:anObject
  39. {
  40.  
  41.     fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
  42.     abort();
  43.     
  44.     return self;
  45. }
  46.  
  47.  
  48. - sendAllCardsTo:anObject
  49. {
  50.  
  51.     fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
  52.     abort();
  53.     
  54.     return self;
  55. }
  56.  
  57.  
  58. - addCard:( CardView * )aCard :sender
  59. {
  60.  
  61.     fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
  62.     abort();
  63.     
  64.     return self;
  65. }
  66.  
  67.  
  68. - removeCard:( CardView * )aCard :sender
  69. {
  70.  
  71.     fprintf( stderr, "Class=%s, received method=%s, superclass not responsible, subclasses should implement", [ self name ], sel_getName( _cmd ));
  72.     abort();
  73.     
  74.     return self;
  75. }
  76.  
  77.  
  78. - setCardsEnabled:( BOOL )flag
  79. {
  80.  
  81.     reactiveCardsFlag = flag;
  82.     
  83.     return self;
  84. }
  85.  
  86.  
  87. - setTrackingEnabled:( BOOL )flag
  88. {
  89.  
  90.     trackingEnabledFlag = flag;
  91.     
  92.     return self;
  93. }
  94.  
  95.  
  96. - ( BOOL )isTrackingEnabled
  97. {
  98.  
  99.     return trackingEnabledFlag;
  100. }
  101.  
  102.  
  103. - trackingHighlighted:( BOOL )flag
  104. {
  105.  
  106.  
  107.     highlightModeFlag = flag;
  108.     
  109.     return [[ self setNeedsDisplay:YES ] update ];
  110. }
  111.  
  112.  
  113. - setFrameMode:( BOOL )flag
  114. {
  115.  
  116.     frameModeFlag = flag;
  117.     [ window addToEventMask:NX_MOUSEENTEREDMASK+NX_MOUSEEXITEDMASK ];
  118.     
  119.     return self;
  120. }
  121.  
  122.  
  123. - baseHolder
  124. {
  125.  
  126.     id    searchView = self,
  127.         lastHolder = self;
  128.     
  129.     
  130.     while( searchView ) {
  131.         id    theSuperview = [ searchView superview ];
  132.         
  133.         if([ theSuperview isKindOf:[ CardHolder class ]])
  134.             lastHolder = theSuperview;
  135.         searchView = theSuperview;
  136.     }
  137.     
  138.     return lastHolder;
  139. }
  140.  
  141.  
  142. - setTitle:( const char * )aTitle
  143. {
  144.  
  145.     free( myTitle );
  146.     strcpy(( myTitle = calloc(( strlen( aTitle ) + 8 ), sizeof( char ))), aTitle );
  147.     
  148.     return self;
  149. }
  150.  
  151.  
  152. - ( BOOL )subviewVisible:aView
  153. {
  154.  
  155.  
  156.     return YES;
  157. }
  158.  
  159.  
  160. - ( List * )holderList
  161. {
  162.  
  163.  
  164.     return subviews;
  165. }
  166.  
  167.  
  168. - ( int )numCardTypeInHolder:( int )aCardTag
  169. {
  170.  
  171.     int        i, cnt;
  172.     
  173.     
  174.     for( i = 0, cnt = 0; i < [ subviews count ]; ++i )
  175.         if([[ subviews objectAt:i ] tag ] == aCardTag )
  176.             ++cnt;
  177.     
  178.     return cnt;
  179. }
  180.  
  181.  
  182. - ( int )numSafetiesInHolder
  183. {
  184.     int        i, cnt;
  185.     
  186.     
  187.     for( i = 0, cnt = 0; i < [ subviews count ]; ++i )
  188.         if( isSafety([ subviews objectAt:i ]))
  189.             ++cnt;
  190.     
  191.     return cnt;
  192. }
  193.  
  194.  
  195. - drawSelf:( NXRect * )rects :( int )rectCount
  196. {
  197.  
  198.     float    c_squared = hypot( NX_WIDTH( &bounds ), NX_HEIGHT( &bounds ));
  199.     float    ourGray = [[ self opaqueAncestor ] backgroundGray ];
  200.     
  201.     
  202.     if( ourGray < 0.0 )
  203.         ourGray = [ window backgroundGray ];
  204.     PSsetgray( ourGray );
  205.     NXRectFill( &bounds );
  206.     if( highlightModeFlag ) {
  207.         PSsetgray( NX_WHITE );
  208.         NXFrameRectWithWidth( &bounds, 1 );
  209.     }
  210.     if( frameModeFlag ) {
  211.         NXRect    frameBounds = bounds;
  212.         
  213.         PSsetgray( NX_BLACK );
  214.         NXInsetRect( &frameBounds, 1.0, 1.0 );
  215.         NXFrameRectWithWidth( &frameBounds, 1 );
  216.     }
  217.     angled_title(( 180 / M_PI * asin( NX_HEIGHT( &bounds ) / c_squared )), c_squared, myTitle );
  218.     
  219.     return self;
  220. }
  221.  
  222.  
  223. @end
  224.